package com.tanhua.server.controller;

import com.tanhua.model.vo.SoundVo;
import com.tanhua.server.service.PeachBlossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 桃花传音 控制层
 */
@RestController
@RequestMapping("/peachblossom")
public class PeachBlossomController {

    @Autowired
    private PeachBlossomService peachBlossomService;

    @PostMapping
    public ResponseEntity sendSound(MultipartFile soundFile) {
        peachBlossomService.sendSound(soundFile);
        return ResponseEntity.ok(null);
    }

    @GetMapping
    public ResponseEntity receiveSound() {
        SoundVo soundVo = peachBlossomService.receiveSound();
        return ResponseEntity.ok(soundVo);
    }

}
